#!/bin/bash

export DEBUGINFOD_URLS="https://debuginfod.fedoraproject.org/ $DEBUGINFOD_URLS"
export DEBUGINFOD_TIMEOUT=300

# On Rawhide, the running kernel packages won't probably be avail in
# configured repos.  Debuginfo isn't a problem, we access that using
# the debuginfod.
__install_deps ()
{
    TMPD=$(mktemp -d)
    pushd $TMPD
    koji download-build --rpm kernel-`uname -r` --arch `uname -i`
    koji download-build --rpm kernel-devel-`uname -r` --arch `uname -i`
    koji download-build --rpm kernel-modules-`uname -r` --arch `uname -i`
    dnf -y install kernel{,-devel,-modules}-`uname -r`.rpm
    popd
    rm -rf $TMPD
}

set -xe

# Install needed packages
stap-prep || __install_deps
stap-prep

# Report installed packages
stap-report

# Set up SELinux so that it allows for userspace probing
setsebool allow_execmod on
setsebool allow_execstack on
setsebool deny_ptrace off

set +xe
